package com.bjsxt.shop.goods.service.impl;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.bjsxt.shop.common.service.impl.BaseServiceImpl;
import com.bjsxt.shop.goods.dao.IAGoodsDao;
import com.bjsxt.shop.goods.pojo.AGoodsCate;
import com.bjsxt.shop.goods.service.IGoodsService;
import com.bjsxt.shop.goods.service.IGoodsStatService;

@Service("goodsStatService")
public class GoodsStatServiceImpl extends BaseServiceImpl implements IGoodsStatService
{
	@Resource
	private IAGoodsDao goodsDao;
	@Resource
	private IGoodsService goodsService;

	@Override
	public List<Map> statCateCountService(Map<String, Object> paramsMap)
	{
		paramsMap.put("statFlag", "cateCount");
		List<Map> resultList = this.goodsDao.statMap(paramsMap);
		Map<String, Object> condMap = new HashMap<String,Object>();
		/* 循环List,根据分类id查询分类表 */
		for (Iterator iterator = resultList.iterator(); iterator.hasNext();)
		{
			Map map = (Map) iterator.next();
			String cateId = map.get("cateId") + "";
			/* 根据分类Id查询分类的对象,获取名称 */
			condMap.clear();
			condMap.put("id", cateId);
			AGoodsCate goodsCate = this.goodsService.findOneGoodsCateService(condMap);
			map.put("cateName", goodsCate.getName());
		}
		return resultList ; 
	}
}
